package com.dhcc.bpm.alarm.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * <p>
 *
 * </p>
 *
 * @author xiafayu
 * @since 2022-02-16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ALARM_RECORD")
@ApiModel(value="AlarmRecord对象", description="告警记录表")
public class AlarmRecord implements Serializable {

    private static final long serialVersionUID=1L;

    @ApiModelProperty(value = "主键")
    @TableId(
            value = "ID",
            type = IdType.ASSIGN_ID
    )
    @JsonSerialize(
            using = ToStringSerializer.class,
            nullsUsing = NullSerializer.class
    )
    private Long id;

    @ApiModelProperty(value = "系统编号")
    @TableField("SYSTEMNO")
    private String systemno;

    @ApiModelProperty(value = "系统名称")
    @TableField("SYSTEMNAME")
    private String systemname;

    @ApiModelProperty(value = "策略名称")
    @TableField("STRATEGY_NAME")
    private String strategyName;

    @ApiModelProperty(value = "策略编号")
    @TableField("STRATEGY_CODE")
    private String strategyCode;

    @ApiModelProperty(value = "策略类型(公共告警、交易告警)")
    @TableField("STRATEGY_TYPE")
    private String strategyType;

    @ApiModelProperty(value = "场景编码/交易代码")
    @TableField("TX_CODE")
    private String txCode;

    @ApiModelProperty(value = "场景描述")
    @TableField("TX_DESC")
    private String txDesc;

    @ApiModelProperty(value = "预警规则")
    @TableField("RULE_DESC")
    private String ruleDesc;

    @ApiModelProperty(value = "告警名称")
    @TableField("NOTICE_NAME")
    private String noticeName;

    @ApiModelProperty(value = "告警编号")
    @TableField("NOTICE_CODE")
    private String noticeCode;

    @ApiModelProperty(value = "网关编码")
    @TableField("GATEWAY_CODE")
    private String gatewayCode;

    @ApiModelProperty(value = "网关名称")
    @TableField("GATEWAY_NAME")
    private String gatewayName;

    @ApiModelProperty(value = "触发方式01定时02事件")
    @TableField("TRIGGER_METHOD")
    private String triggerMethod;

    @ApiModelProperty(value = "告警时间yyyymmddHH24miss")
    @TableField("ALARM_TIME")
    private String alarmTime;

    @ApiModelProperty(value = "告警流水号")
    @TableField("ALARM_TRANNO")
    private String alarmTranno;

    @ApiModelProperty(value = "通知状态00通知成功01通知失败")
    @TableField("NOTICE_STATUS")
    private String noticeStatus;

    @ApiModelProperty(value = "通知次数")
    @TableField("NOTICE_TIMES")
    private BigDecimal noticeTimes;

    @ApiModelProperty(value = "预警消息")
    @TableField("ALARM_MESSAGE")
    private String alarmMessage;

    @ApiModelProperty(value = "通知错误原因")
    @TableField("ALARM_REASON")
    private String alarmReason;

    @ApiModelProperty(value = "接收对象名称")
    @TableField("OBJECT_NAME")
    private String objectName;

    @ApiModelProperty(value = "处理标志01已处理02待处理03无需处理")
    @TableField("DEAL_STATUS")
    private String dealStatus;

    @ApiModelProperty(value = "处理时间yyyymmddhh24miss")
    @TableField("DEAL_TIME")
    private String dealTime;

    @ApiModelProperty(value = "处理人员/系统名称")
    @TableField("DEAL_OBJECT")
    private String dealObject;

    @ApiModelProperty(value = "处理人员/系统编码")
    @TableField("DEL_OBJNO")
    private String delObjno;

    @ApiModelProperty(value = "处理人员/系统联系方式")
    @TableField("DEAL_CONTACT")
    private String dealContact;

    @ApiModelProperty(value = "通知方式")
    @TableField("NOTICE_METHOD")
    private String noticeMethod;

    @ApiModelProperty(value = "描述")
    @TableField("RAMARK")
    private String ramark;

    public String getAlarmReason() {
        return alarmReason;
    }

    public void setAlarmReason(String alarmReason) {
        if(!StringUtils.isBlank(alarmReason)){
            if(alarmReason.length()>200){
                alarmReason = alarmReason.substring(0,200);
            }
        }
        this.alarmReason = alarmReason;
    }
}
